package com.ruoyi.accountant.service.impl;

import com.ruoyi.accountant.dao.BalanceDao;
import com.ruoyi.accountant.domain.Balance;
import com.ruoyi.accountant.mapper.BalanceMapper;
import com.ruoyi.accountant.service.BalanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BalanceServiceImpl implements BalanceService {
    // @Autowired
//    private BalanceDao balanceDao;

    @Autowired
    private BalanceMapper balanceMapper;

    @Override
    public void save(Balance balance) {
        balanceMapper.insert(balance);
    }

    @Override
    public void updata(Balance balance) {
        balanceMapper.updateByPrimaryKeySelective(balance);
    }

    @Override
    public List<Balance> findByAccount(Long aid) {
        return balanceMapper.findAllByOfAccount(aid);
    }

    @Override
    public Balance findByOfAccountAndOfCurrency(Long aid, Integer ofCurrency) {
        return balanceMapper.findAllByOfAccountAndOfCurrency(aid, ofCurrency);
    }
}
